//
//  test2.h
//  TestMac
//
//  Created by 小星星吃KFC on 2021/6/4.
//
#import <Foundation/Foundation.h>

static
void test2(void){
    
    TestString *test = [[TestString alloc]init];
    
    NSString *testStr = [NSString stringWithFormat:@"11"];
    /// 因为 NSMutableString 为子集,所以可以赋值给 NSString 不报错
    test.strongStr = testStr;
    test.copyedStr = testStr;
    
    NSLog(@"修改值前:");
    NSLog(@"testStr=%p,valyue = %@", testStr,testStr);
    
    NSLog(@"strongStr=%p,valyue = %@", test.strongStr,test.strongStr);
    
    NSLog(@"copyedStr=%p,valyue = %@", test.copyedStr,test.copyedStr);
    
    /// 通过可变集合方式修改值,地址不变
    
    testStr = @"22";
    NSLog(@"修改值后:");
    /// testStr 为可变集合时候,通过可变集合修改,
    NSLog(@"testStr=%p,valyue = %@", testStr,testStr);
    /// strongStr ,因为是浅拷贝,也会被同时修改
    NSLog(@"strongStr=%p,valyue = %@", test.strongStr,test.strongStr);
    /// copyedStr 因为是深拷贝,不会被修改
    NSLog(@"copyedStr=%p,valyue = %@", test.copyedStr,test.copyedStr);
}



NSComparisonResult dateSort1(id obj1, id obj2, void *context) {
    NSString* d1=obj1;
    NSString* d2=obj2;
    NSLog(@"obj1 = %@,obj2 = %@",obj1,obj2);
    
    
    //    NSLog(@"%@ %@ %d\n", d1, d2, [d1 compare:d2]);
    //
    //    NSInteger k = [d1 compare:d2];
    //
    //    if(k == 1)
    //    {
    //        NSLog(@"%@ %@ %d\n", d1, d2, [d1 compare:d2]);
    //
    //        return NSOrderedAscending;
    //    }
    //
    //    if(k == 0)return NSOrderedSame;
    //    if(k == -1)return NSOrderedDescending;
    
    return [d1 compare:d2];
}


